#include<iostream>
#include<cstdio>
const int N = 1e4 + 10;
int Year[N];
using namespace std;
bool is_prime(int n)
{
	if (n % 400 == 0 || (n % 100 != 0 && n % 4 == 0)) {
		return true;
	}
	return false;
}
void Year_1()
{
	for (int i = 1; i < N; i++) {
		if (is_prime(i)) {
			Year[i] = 365;
		}
		else {
			Year[i] = 366;
		}
	}
}
int main()
{
	int t;
	cin >> t; 
	while (t--) {
		int year = 0;
		int month = 0;
		int day;
		scanf_s("%d-%d-%d", &year, &month, &day);
		//cout << year << " " << month << " " << day << " ";
		Year_1();
		int sum = 0;
			
	}
	return 0;
}